package com.samuel.igoodman.web.account;

import java.util.List;

import com.samuel.igoodman.dao.account.UserGroupDao;
import com.samuel.igoodman.entity.account.UserGroup;
import com.samuel.igoodman.entity.account.UserGroupMember;
import com.samuel.igoodman.entity.account.Userinfo;
import com.samuel.igoodman.web.base.BaseAction;

@SuppressWarnings("serial")
public class UserGruopAction extends BaseAction {
	
	/*【添加小组】*/
	public String save(){
		if("save".equals(op)){
			Userinfo userinfo = getCurrUserinfo();
			userGroup.setUserinfoId(userinfo.getId());
			userGroup.Save();
			return DETAIL;
		}
		return SUCCESS;
	}
	
	/*【用户详情】*/
	public String detail(){
		if(null!=userGroup && userGroup.getId()>0){
			userGroup = userGroup.Get(userGroup.getId());
		}
		return SUCCESS;
	}
	
	/*【小组列表】*/
	public String list(){
		userGroupList = UserGroupDao.getAllUserGroup(pageNo, pageSize);
		return SUCCESS;
	}
	
	/* 【申请加入】 */
	public String apply(){
		if(null!=userGroup && userGroup.getId()>0){
			UserGroupMember ugu = new UserGroupMember();
			ugu.setUserGroupId(userGroup.getId());
			ugu.setUserinfoId(getCurrUserinfo().getId());
			ugu.setStatus(0);
			ugu.Save();
		}
		return SUCCESS;
	}
	
	/* 【修改成员】 */
	public String update(){
		
		return SUCCESS;
	}
	
	// -------------------- 属性  ---------------------

	private UserGroup userGroup;
	private List<UserGroup> userGroupList;
	
	// -------------------- GET SET  -----------------

	public UserGroup getUserGroup() {
		return userGroup;
	}

	public void setUserGroup(UserGroup userGroup) {
		this.userGroup = userGroup;
	}

	public List<UserGroup> getUserGroupList() {
		return userGroupList;
	}

	public void setUserGroupList(List<UserGroup> userGroupList) {
		this.userGroupList = userGroupList;
	}
	
	
	
	
	
}
